package jeconbond.experiment.natural.prodpossibfrontier;

import jeconbond.economic.resources.ResourceType;
import jeconbond.economic.resources.IResourceType;
import jeconbond.economic.systems.natural.NaturalRRSFactory;
import jeconbond.experiment.natural.prodpossibfrontier.generate.*;
import jeconbond.experiment.JEBExperimentFlow;
import jeconbond.experiment.ui.reportage.ProductionPossibilityER2CConverter;
import laboratoryQ.flatness.Point;
import laboratoryQ.experiment.settings.ReflectionBasedSettingsContainer;
import laboratoryQ.experiment.ui.reportage.ExperimentReportage;

public class MainThunderball {
	public static IResourceType IRON = new ResourceType("Iron");
	public static IResourceType TANK = new ResourceType("Tank");
	public static IResourceType TRAKTOR = new ResourceType("Traktor");
	
	public static void main(String[] args) {
		main1(args);
		main2(args);
	}
	
	public static void main2(String[] args) {
		JEBExperimentFlow experimentFlow = new JEBExperimentFlow();
		ConneryExperimentSettings settings = new ConneryExperimentSettings();
		settings.initialise();

		settings.stepSize = 50;
		settings.stepCount = 80;
		settings.agentPerStep = settings.stepCount / 10;
		settings.agentsCount = settings.stepCount + settings.agentPerStep - 1;
		settings.chainLength = 5;
		settings.tankMul = 1.0;
		settings.traktorMul = 2.5;
		
		settings.rrsFactory = new NaturalRRSFactory();
		settings.experiment = experimentFlow;
		settings.randomSeed = 0.0;

		settings.ironResource = IRON;
		settings.tankResource = TANK;
		settings.traktorResource = TRAKTOR;
		settings.resources = new IResourceType[] { IRON, TANK, TRAKTOR };
		settings.ironByStep = 1.3 * settings.agentsCount * settings.agentPerStep / settings.stepCount;
		settings.fluctuationPart = 0.07;
		
		settings.relationBoard = 5.0;
		settings.relationDistPercent = 0.4;
//		settings.branchLength = 3;
		settings.branchesCount = 7; 
		settings.zeroPoint = new Point(0.0, 0.0);
		settings.goalsArray = new double[] {};
		
		settings.validate();
		
		ReflectionBasedSettingsContainer settCont =
			new ReflectionBasedSettingsContainer(settings);
		settCont.sortFields(
				"stepSize",
				"stepCount",
				"agentsCount",
				"chainLength",
				"tankMul",
				"traktorMul",
				"randomSeed"
		);
		
		experimentFlow.automataGenerator = new AdaptiveProdPPFGraphGenerator(); 
		experimentFlow.agentCreator = new SetAuditStrategyBasedAgentsCreator();
		experimentFlow.engineInitialiser = new ProdPossibEngineInitialiser();

		ExperimentReportage experimentReportage =
			ExperimentReportage.newExperiment2componentReportage(
					settCont,
					new ProductionPossibilityER2CConverter("Thunderball experiment no concPr no util")
			);
		experimentReportage.showReportageFrame(args);

//		JEBExperimentControlKit thunderballExpKit = new JEBExperimentControlKit(
//				settCont,
//				UIUtils.COLORS_COLLECTION,
//				"Thunderball experiment no concPr no util"
//		);
//		thunderballExpKit.setViewTitles(TITLES);
//
//		JEBExperimentUIFront.showControlKit(thunderballExpKit);
	}
	
	public static void main1(String[] args) {
		JEBExperimentFlow experimentFlow = new JEBExperimentFlow();
		ConneryExperimentSettings settings = new ConneryExperimentSettings();
		settings.initialise();

		settings.stepSize = 50;
		settings.stepCount = 80;
		settings.agentPerStep = settings.stepCount / 5;
		settings.agentsCount = settings.stepCount + settings.agentPerStep - 1;
		settings.chainLength = 5;
		settings.tankMul = 1.0;
		settings.traktorMul = 2.5;
		
		settings.rrsFactory = new NaturalRRSFactory();
		settings.resources = new IResourceType[] { IRON, TANK, TRAKTOR };
		settings.experiment = experimentFlow;
		settings.randomSeed = 0.0;

		settings.ironResource = IRON;
		settings.tankResource = TANK;
		settings.traktorResource = TRAKTOR;
		settings.ironByStep = 1.3 * settings.agentsCount * settings.agentPerStep / settings.stepCount;
		settings.fluctuationPart = 0.07;

		settings.relationBoard = -2.0;
		settings.relationDistPercent = -2.0;
//		settings.branchLength = -2;
		settings.branchesCount = -2;
		settings.zeroPoint = new Point(0.0, 0.0);
		settings.goalsArray = new double[] {};
		
		settings.validate();
		
		ReflectionBasedSettingsContainer settCont = 
			new ReflectionBasedSettingsContainer(settings);
		settCont.sortFields(
				"stepSize",
				"stepCount",
				"agentsCount",
				"chainLength",
				"tankMul",
				"traktorMul",
				"randomSeed"
		);
		
		experimentFlow.automataGenerator = new StaticProdPPFGraphGenerator(); 
		experimentFlow.agentCreator = new PlanWalkerStrategyBasedAgentsCreator();
		experimentFlow.engineInitialiser = new ProdPossibEngineInitialiser();

		ExperimentReportage experimentReportage =
			ExperimentReportage.newExperiment2componentReportage(
					settCont,
					new ProductionPossibilityER2CConverter("Thunderball experiment no concPr no util")
			);
		experimentReportage.showReportageFrame(args);

//		JEBExperimentControlKit thunderballExpKit = new JEBExperimentControlKit(
//				settCont,
//				UIUtils.COLORS_COLLECTION,
//				"Thunderball experiment no concPr no util"
//		);
//		thunderballExpKit.setViewTitles(TITLES);
//
//		JEBExperimentUIFront.showControlKit(thunderballExpKit);
	}
}
